home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DEMOS / PUMPSRC.ZIP / SHOW.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-27  |  4.1 KB  |  154 lines

  1.  
  2. #include "pump.h"
  3.  
  4. #include <stdio.h>
  5. #include <string.h>
  6. #include <llkey.h>
  7. #include <llscreen.h>
  8. #include <jclib.h>
  9. #include <ctype.h>
  10. #include <stdarg.h>
  11. #include <vga.h>
  12. #include <vbl.h>
  13.  
  14. PRIVATE byte *image;
  15. PRIVATE byte pal[768];
  16. PRIVATE int time;
  17. PRIVATE int state;
  18. PRIVATE int come_in_finished = 0;
  19. PRIVATE int come_out_finished = 0;
  20.  
  21. #define NSECS 2
  22. #define SHOW_TIME 1
  23.  
  24. int tabla[70*NSECS] = {
  25. #include "tabla.h"
  26. };
  27.  
  28.  
  29. void SHOW_DoFrame(void) {
  30.     int i, localtime = time, scantime;
  31.     byte *p = LLS_Screen[0];
  32.     byte *q = image;
  33.  
  34.     if (state == 0) {
  35.         for (i = 0; i < 200; i++) {
  36.             scantime = localtime;
  37.             if (scantime >= 70*NSECS)
  38.                 scantime = 70*NSECS-1;
  39.             if (scantime < 0)
  40.                 scantime = 0;
  41.             memcpy(p+tabla[scantime], q, 320-tabla[scantime]);
  42.             p += 320;
  43.             q += 320;
  44.             if (!(i & 1)) {
  45.                 localtime -= 1;
  46.                 if (localtime == -1)
  47.                     localtime = 0;
  48.             }
  49.         }
  50.         if (localtime >= 70*NSECS-1)
  51.             come_in_finished = 1;
  52.         else
  53.             come_in_finished = 0;
  54.     } else if (state == 1) {
  55.         memcpy(p, image, 64000);
  56.     } else if (state == 2) {
  57.     } else if (state == 3) {
  58.         for (i = 0; i < 200; i++) {
  59.             scantime = 70*NSECS + 35 - localtime;
  60.             if (scantime >= 70*NSECS)
  61.                 scantime = 70*NSECS-1;
  62.             if (scantime < 0)
  63.                 scantime = 0;
  64.             memset(p, 0, tabla[scantime]);
  65.             memcpy(p+tabla[scantime], q, 320-tabla[scantime]);
  66.             p += 320;
  67.             q += 320;
  68.             if (!(i & 1)) {
  69.                 localtime -= 1;
  70.                 if (localtime == -1)
  71.                     localtime = 0;
  72.             }
  73.         }
  74.         if (localtime >= 35+70*NSECS-1)
  75.             come_out_finished = 1;
  76.         else
  77.             come_out_finished = 0;
  78.     }
  79. }
  80.  
  81. void SHOW_Do(void) {
  82.     int i;
  83.     int delta;
  84.  
  85.     memset(LLS_Screen[0], 0, LLS_Size);
  86.     LLS_Update();
  87.  
  88.     LLS_SetMode(LLSM_DIRECT, LLSVM_MODE13);
  89.  
  90.     if (JCLIB_Load("image.pal", pal, 768) != 768) {
  91.         BASE_Abort("load image.pal");
  92.     }
  93.     image = NEW(320*200);
  94.     if (!image) {
  95.         BASE_Abort("not enough mem for image.pix");
  96.     }
  97.     if (JCLIB_Load("image.pix", image, 64000) != 64000) {
  98.         BASE_Abort("load image.pix");
  99.     }
  100.     VBL_FadePos = 0;
  101.     VBL_FadeSpeed = 0;
  102.     VBL_DumpPalette(pal, 0, 256);
  103.  
  104. /*
  105.     if (JCLIB_Load("image.pal", pal, 768) != 768) {
  106.         BASE_Abort("load image.pal");
  107.     }
  108.     image = NEW(320*200);
  109.     if (!image) {
  110.         BASE_Abort("not enough mem for image.pix");
  111.     }
  112.     if (JCLIB_Load("image.pix", image, 64000) != 64000) {
  113.         BASE_Abort("load image.pix");
  114.     }
  115.     VBL_DumpPalette(pal, 0, 256);
  116. */
  117.     VBL_VSync(0);
  118.     time = 0;
  119.     state = 0;
  120.     while (!LLK_SpacePressed) {
  121.         SHOW_DoFrame();
  122.         delta = VBL_VSync(1);
  123.         if (state == 0) {
  124.             if (come_in_finished) {
  125.                 state = 1;
  126.                 time = 0;
  127.             }
  128.         } else if (state == 1) {
  129.             state = 2;
  130.         } else if (state == 2) {
  131.             ///////////////////////////////////////////////////////////////
  132.             ///////////////////////////////////////////////////////////////
  133.             ///////////////////////////////////////////////////////////////
  134.             // Poner aquí la condición para que deje de mostrar la imagen
  135.             // estática
  136.             ///////////////////////////////////////////////////////////////
  137.             ///////////////////////////////////////////////////////////////
  138.             ///////////////////////////////////////////////////////////////
  139.             if ((time <= 70*SHOW_TIME) && (time+delta > 70*SHOW_TIME)) {
  140.                 state = 3;
  141.                 time = 0;
  142.             }
  143.         } else if (state == 3) {
  144.             if (come_out_finished)
  145.                 break;
  146.         }
  147.         time += delta;
  148.     }
  149.     DISPOSE(image);
  150.  
  151.     LLS_SetMode(LLSM_VIRTUAL, LLSVM_MODE13);
  152.  
  153. }
  154.